package com.ckk.eurekaclient.controller;

import com.ckk.eurekaclient.pojo.RespBean;
import com.ckk.eurekaclient.vo.req.MarkerReqVo;
import com.ckk.eurekaclient.service.IMarkerService;
import com.ckk.eurekaclient.vo.req.QueryMarkEditionReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 
 * @author zhujunjun
 * @date 2021/05/20 09:12
 **/
@Api(tags = "标记点")
@RequestMapping("map/mark")
@RestController
public class MarkerController {

    @Autowired
    private IMarkerService markerService;

    @ApiOperation(value = "查询标记点历史版本")
    @PostMapping("/queryMarkEdition")
    public RespBean queryMarkEdition(@RequestBody QueryMarkEditionReqVo reqVo) {
        return RespBean.success("操作成功", markerService.queryMarkEdition(reqVo));
    }

    @ApiOperation(value = "添加打点")
    @PostMapping("/addMarker")
    public RespBean addMarker(String layer, String xy) {
        String pic = "";
        synchronized (this) {
            pic = markerService.addMarker(layer, xy);
        }
        return RespBean.success("操作成功", pic);
    }

    @ApiOperation(value = "删除打点")
    @PostMapping("/deleteMarker")
    public RespBean deleteMarker(String guid) {
        markerService.deleteMarker(guid);
        return RespBean.success("操作成功");
    }

    @ApiOperation(value = "修改打点")
    @PostMapping("/updateMarker")
    public RespBean updateMarker(@RequestBody MarkerReqVo reqVo) {
        markerService.updateMarker(reqVo);
        return RespBean.success("操作成功");
    }


    @ApiOperation(value = "获取标记点")
    @GetMapping("/getMarker")
    public RespBean getMarker() {
        return RespBean.success("获取成功", markerService.getMark());
    }

    @ApiOperation(value = "通过layer获取标记点")
    @GetMapping("/getMarkerByLayer")
    public RespBean getMarkerByLayer(String id) {
        return RespBean.success("获取成功", markerService.getMarkByLayer(id));
    }


}
